﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data.OleDb;
using System.Data;

namespace Web_HengliSeed.BLL
{
    public class BringInfo
    {
        /// <summary>
        /// 获取一条分类数据
        /// </summary>
        /// <param name="strClassID"></param>
        /// <returns></returns>
        public static OleDbDataReader GetNoteMes(string strBringID)
        {
            try
            {
                OleDbParameter[] parm = { new OleDbParameter("@T_BringID", strBringID) };
                return ClassFile.AccessHelper.ExecuteReader(ClassFile.AccessHelper.ConnectionString, " SELECT * FROM T_BringMes WHERE T_BringID=@T_BringID ", parm);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static OleDbDataReader GetNoteMesAll(string language)
        {
            try
            {
                string sql = string.Format(" SELECT * FROM T_BringMes WHERE T_Language='{0}' and T_IsShow='1' ",language);
                return ClassFile.AccessHelper.ExecuteReader(ClassFile.AccessHelper.ConnectionString, sql);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 分页查询产品信息
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageCount"></param>
        /// <returns></returns>
        public static DataTable GetNoteMes(int PageIndex, int PageSize, out int PageCount, out int RecordCount, string strWhere)
        {
            try
            {
                string strSql = " SELECT * FROM T_BringMes ";
                string strShow = " * ";
                return ClassFile.AccessHelper.ExecutePager(PageIndex, PageSize, "T_BringID", strShow, strSql, strWhere, " T_BringID DESC ", out PageCount, out RecordCount);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 编辑产品数据
        /// </summary>
        /// <param name="ClassID"></param>
        /// <param name="strClassName"></param>
        /// <param name="strKey"></param>
        /// <param name="strDes"></param>
        /// <returns></returns>
        public static bool EditBringMes(string T_BringID, string T_BringTitle, string T_BringImage, string T_BringNote, string T_Language, bool T_IsShow)
        {
            try
            {
                string strSql = " INSERT INTO  T_BringMes (T_BringTitle,T_BringImage,T_BringNote,T_Language,T_IsShow) VALUES (@T_BringTitle,@T_BringImage,@T_BringNote,@T_Language,@T_IsShow) ";
                if (!string.IsNullOrEmpty(T_BringID))
                {
                    strSql = " UPDATE T_BringMes SET T_BringTitle=@T_BringTitle,T_BringImage=@T_BringImage,T_BringNote=@T_BringNote,T_Language=@T_Language,T_IsShow=@T_IsShow WHERE  T_BringID=@T_BringID ";
                }
                OleDbParameter[] parm = { new OleDbParameter("@T_BringTitle", T_BringTitle),
                                                           new OleDbParameter("@T_BringImage", T_BringImage),
                                                           new OleDbParameter("@T_BringNote", T_BringTitle),
                                                           new OleDbParameter("@T_Language", T_Language),
                                                            new OleDbParameter("@T_IsShow", (T_IsShow ? "1" : "0")),
                                                           new OleDbParameter("@T_BringID", T_BringID)
                                                            };
                //parm[5].Value = T_IsShow;

                return (ClassFile.AccessHelper.ExecuteNonQuery(ClassFile.AccessHelper.ConnectionString, strSql, parm) > 0) ? true : false;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 删除信息
        /// </summary>
        /// <param name="strClassID"></param>
        /// <returns></returns>
        public static bool DeBringMes(string BID)
        {
            try
            {
                OleDbParameter[] parm = { new OleDbParameter("@T_BringID", BID) };
                bool ReClass = (ClassFile.AccessHelper.ExecuteNonQuery(ClassFile.AccessHelper.ConnectionString, " DELETE FROM T_BringMes WHERE T_BringID IN (@T_BringID) ", parm) > 0) ? true : false;
                return ReClass;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
